package com.example.all4.condition;

import java.util.Map;

public class SConditionChianConfig {

    private Map<String,Object> param;
    private SCondition isLoginsCondition;
    private SCondition isBuyedsCondition;
    private SCondition isLearnRecordsCondition;
    private SCondition isFreeLessonsCondition;

    public SConditionChianConfig(Map<String,Object> param){
        this.param = param;
    }

    private void init(){
        //loginCondition
        isLoginsCondition = new DeaultSCondition(0,param);
        isLoginsCondition.bind(EventList.getIsLoginEvent());

        //loginCondition
        isBuyedsCondition = new DeaultSCondition(1,param);
        isBuyedsCondition.bind(EventList.getIsBuyEvent());
        //loginCondition
        isLearnRecordsCondition = new DeaultSCondition(2,param);
        isLearnRecordsCondition.bind(EventList.getIsLearnRecord());
        //loginCondition
        isFreeLessonsCondition = new DeaultSCondition(3,param);
        isFreeLessonsCondition.bind(EventList.getIsFreeLessonEvent());
        isFreeLessonsCondition.bindTrueEvent(EventList.getIsFreeLessonTrueEvent());
    }

    public SCondition getSConditionBySinceType(Integer sinceType){
        init();
        switch (sinceType){
            case 0:
                isLoginsCondition.nextTrue(isBuyedsCondition);
                isBuyedsCondition.nextTrue(isLearnRecordsCondition);
                isLearnRecordsCondition.nextFalse(isFreeLessonsCondition);

                isLoginsCondition.nextFalse(isFreeLessonsCondition);
                isBuyedsCondition.nextFalse(isFreeLessonsCondition);
                return isLoginsCondition;
            default:


        }

        return null;
    }

}
